//if(true) exitWith{};

//等待玩家
waitUntil {count allPlayers > 0};
//刷待久的惩罚 40分钟一次

//每个玩家都记录位置和时间，一旦超过时间就有惩罚
_dis = 400;
_dt =  1800;
_dtSleep = 60;

if(Param_Debug == 1)then{
	_dis = 400;
	_dt =  600;
	_dtSleep = 30;
};

private _pos = getMarkerPos "mk_players";

while{true} do
{
	Sleep _dtSleep;//60s判断一次，
	{
		private _do = true;
		//玩家死亡、在出身点，就重新计时
		if(!alive _x
		|| {_x distance2D _pos < 500})then{
			_do = false;
			_x setVariable ["as_player_move_time", time];
		};
		
		//玩家倒地，延缓计时
		if(_do
		&& {_x getVariable ['FAR_isUnconscious',0] == 1}) then{
			_do = false;
			_x setVariable ["as_player_move_time", (_x getVariable ["as_player_move_time", 0]) + _dtSleep];
		};
		
		if(_do)then{
			//初始值为玩家重生点，这样就不会误判
			_perPos = _x getVariable ["as_player_pos", _pos];
			_curPos = getPos _x;
			if(_perPos distance2D _curPos > _dis)then
			{//大于距离，则刷新位置和时间
				_x setVariable ["as_player_pos", _curPos];
				_x setVariable ["as_player_move_time", time];
			}
			else{
				if(((_x getVariable ["as_player_move_time", 0]) + _dt) < time)then
				{
					//更新状态
					_x setVariable ["as_player_pos", _curPos];
					_x setVariable ["as_player_move_time", time];
					
					if(Param_Debug == 1)then{systemChat "玩家触发呆的时间太久！"};
					[getPos _x, 2.0] spawn fn_aiNeedSupport;
					"LeadTrack04_F" remoteExec ["playMusic"];
					//刷兵，由于每个玩家都会触发，所以还是不要太多了
					/*
					if(call fn_canSpawnAI) then{
						
						private _group = [getPos _x, call fn_aiNum * 0.75, 6, 600, 3, true] call fn_createGroup;
						[_group, _x] call fn_addWaypoint;
						[_group] spawn fn_controlGroup;
						
						//突击队
						if(random 100 < 25)then{
							uiSleep 60;
							[selectRandom asg_normal, getPos _x] spawn fn_createG;
						};
						
					};
					*/
					//99
					/*
					if(random 100 < 9)then{
						uiSleep 60;
						[asg_10, getPos _x] spawn fn_createG;
					};
					*/
				};
			};
		};
	}forEach (call fn_getPlayerRed);
};

